package main

import (
	"fmt"
	"maps"
)

func main() {
	// create an empty map
	m := make(map[string]int)

	// set key/value pairs
	m["k1"] = 7
	m["k2"] = 13

	fmt.Println("map:", m)

	// get a value for a key
	v1 := m["k1"]
	fmt.Println("v1:", v1)

	// if the key doesn't exist, zero value of the value type is returned
	v3 := m["k3"]
	fmt.Println("v3:", v3)

	fmt.Println("len:", len(m))

	// delete key/value pair
	delete(m, "k2")
	fmt.Println("map:", m)

	// remove all key/value paris
	clear(m)
	fmt.Println("map:", m)

	// indicates if the key was present in the map
	_, prs := m["k2"]
	fmt.Println("prs:", prs)

	// declare and initialize a new map
	n := map[string]int{
		"foo": 1,
		"bar": 2,
	}
	fmt.Println("map:", n)

	// check map equals
	n2 := map[string]int{
		"foo": 1,
		"bar": 2,
	}
	if maps.Equal(n, n2) {
		fmt.Println("n == n2")
	}
}
